﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YanhuaMMO;

/// <summary>
/// 消除3d透视效果
/// </summary>
//[ExecuteInEditMode]
public class PerspectiveScale: Base
{
    public Camera cameraRd = null;
    Vector3 cameraPos = Vector3.zero;
    Vector3 pos = Vector3.zero;
    void Start()
    {
        Transform tCamera = facade.GetManager<PanelManager>(ManagerName.Panel).CameraRound;
        if(cameraRd == null)
            cameraRd = tCamera.Find("CameraRound").GetComponent<Camera>();
        cameraPos = cameraRd.gameObject.transform.localPosition;
    }

    private void LateUpdate()
    {
        if (pos.z == gameObject.transform.position.z && pos.x == gameObject.transform.position.x) return;
        pos = gameObject.transform.position;
        gameObject.transform.localScale = Vector3.one * 1.6f * Vector3.Distance(pos,cameraPos) / cameraRd.fieldOfView;
    }

}
